<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <script src="/html/js/util.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
    <title>商品查询</title>
</head>

<script>
    window.onload = async function () {
        let productId = getQuery("productId");
        let param = {productId: productId};
        let p = await ajaxGet("/product/findById", param);
        console.log(p);
        let str = "";
        str += "<div style='display: flex;justify-content: center'>"
        str += "<div>";
        str += `<div style="margin: 20px">产品名：${p.productName}</div>`;
        str += `<img style="height: 400px" src='/html/imgs/${p.productImg}'>`;
        str += `<div style="margin: 20px">产品价格：${p.productPrice}</div>`;
        str += `<div style="margin: 20px">已售出：${p.soldNum} 件</div>`;
        str += `<div style="margin: 20px">产地：${p.productLocation}</div>`;
        str += `<div style="margin: 20px">生产日期：${p.productDate}</div>`;
        str += `<button type="button" class="layui-btn" onclick="addToShopCar(${p.productId})">添加至购物车</button>`;
        str += `<button type="button" class="layui-btn"><a href="/html/index.html">返回</a></button>`;
        str += `<button type="button" class="layui-btn"><a href="/html/custom/shop.html">查看购物车</a></button>`;
        str += "</div>";
        $("productContent").innerHTML = str;
    }
</script>


<body>
<div id="productContent" style="display: flex;justify-content: center">

</div>
</body>
</html>